
import { userInfoStore } from '../../store/userInfo'
import api from '../../api/index'

const app = getApp()

Page({

  data: {
    userLevel: 0,
    actid:0,
    actType: 0,
    introImage:'',
    prize:null,
    f:'',
  },
  
  onLoad: function (options) {    
    let self = this
    let actid = options.actid;
    let frm = options.f;
    if(frm){
      this.setData({
        userLevel: userInfoStore.userInfo.level,
        actid: actid,
        f:frm
      });
    }else{
      this.setData({
        userLevel: userInfoStore.userInfo.level,
        actid: actid,
      });
    }

    api.getActivityDetail({ actid: actid}).then(res => {
      let {result} = res;
      self.setData({
        actType: result.type,
        introImage: result.detail
      },()=>{
        if (self.data.actType == 10){
          api.lotteryWinners({
            activityId: (self.data.actid==6?4:1)
          }).then(res => {
            self.setData({
              prize:res.result
            })
          });
        }
      })
      wx.setNavigationBarTitle({
        title: result.title
      })
    })


  },

  onShow:function(){
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    getApp().share();
  }
})